﻿<%@ Page Language="C#" MasterPageFile="~/RIDHome.Master" AutoEventWireup="true" CodeBehind="EmailAddress.aspx.cs" Inherits="ResearchId.Validation.EmailAddress" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <p>
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            onrowcommand="GridView1_RowCommand">
            <Columns>
                <asp:BoundField DataField="EmailAddress" HeaderText="EmailAddress" 
                    ReadOnly="True" SortExpression="EmailAddress" />
                <asp:TemplateField HeaderText="Validation" SortExpression="IsValidated">
                    <ItemTemplate>
                        <asp:Panel runat="server" ID="pnlValidated" Visible="<%# (bool)Eval(&quot;IsValidated&quot;) %>">
                        Validated</asp:Panel>
                        <asp:Panel runat="server" ID="pnlValidate" Visible="<%# !(bool)Eval(&quot;IsValidated&quot;) %>">
                            <asp:TextBox runat="server" ID="tbValidate" />
                            <asp:Button CausesValidation="false" runat="server" Text="Validate" ID="btnValidate" CommandArgument="<%# Eval(&quot;EmailAddress&quot;) %>" CommandName="Validate"/>
                        </asp:Panel>
                    </ItemTemplate>
                </asp:TemplateField>
                 <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Panel runat="server" ID="pnlMakePrimary" Visible="<%# !(bool)Eval(&quot;IsPrimary&quot;) && (bool)Eval(&quot;IsValidated&quot;) %>">
                            <asp:Button runat="server" Text="Make Primary" CausesValidation="false" ID="btnMakePrimary" CommandArgument="<%# Eval(&quot;EmailAddress&quot;) %>" CommandName="Primary" />
                        </asp:Panel>
                        <asp:Panel runat="server" ID="pnlIsPrimary" Visible="<%# (bool)Eval(&quot;IsPrimary&quot;) %>">                            
                            Primary</asp:Panel>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Panel runat="server">
                            <asp:Button runat="server" Text="Remove" CausesValidation="false" ID="btnDelete" CommandArgument="<%# Eval(&quot;EmailAddress&quot;) %>" CommandName="myRemove" />
                        </asp:Panel>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
        <br />
        <br />
        <asp:TextBox runat="server" ID="tbAddEmail" Width="200px" />
        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
            ControlToValidate="tbAddEmail" ErrorMessage="*"></asp:RequiredFieldValidator>
        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" 
            ControlToValidate="tbAddEmail" ErrorMessage="*" 
            ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
        <asp:Button runat="server" Text="Add Email" ID="btnAddEmail" 
            onclick="btnAddEmail_Click" />
    </p>
    <p>
        <asp:Button ID="Back" runat="server" CausesValidation="false" Text="Back" 
            onclick="Back_Click" />
    </p>
</asp:Content>
